﻿using System;
using RpcClient.Interface;
using RpcSyncService.Interface;

namespace RpcSyncService.Accredit
{
    [RpcClient.Attr.UnityName("db")]
    [RpcClient.Attr.ClassLifetimeAttr(RpcClient.Attr.ClassLifetimeType.单例)]
    internal class DbAccredit : IAccreditCollect
    {
        private IUnityCollect _Unity;
        public DbAccredit(IUnityCollect unity)
        {
            _Unity = unity;
        }
        public bool Get(Guid accreditId, out IAccreditToken token)
        {
            token = _Unity.Resolve<IAccreditToken>("db");
            return token.Init(accreditId);
        }
        public void Accredit(AccreditToken token)
        {
            IAccreditToken accredit = _Unity.Resolve<IAccreditToken>("db");
            accredit.Create(token);
        }
    }
}
